
function showdiv(obj)
{
    var inputid = obj.id;
    
    if (!getobj("messagediv"))
    {
        //若尚未创建就创建层
        crertdiv("" , "div" , "messagediv" , "messagediv");
        //创建层"messagediv"
        getTagName("html")[0].className += " video-modal"; 
        crertdiv("messagediv" , "div" , "messagemodal" , "messagemodal");

        //创建"请刷新"div
        //crertdiv("messagemodal", "video", "videomodal", "videomodal");

        //播放视频
        //startVideo("themes/mb5_com_cn/images/video/小普形象篇一.mp4", 868, 505, "controls");
		crertdiv("messagemodal", "div", "flash_box", "flash_box");
        getobj("flash_box").innerHTML = '<embed width="100%" height="100%" align="top"'+
                                               'pluginspage="//www.macromedia.com/go/getflashplayer"' +
                                               'type="application/x-shockwave-flash" allowscriptaccess="never"'+
                                               'allowfullscreen="true" wmode="transparent" name="myFlash"'+
                                               'swliveconnect="true" quality="high"'+
                                               'src="            //s.yuntv.letv.com/bclouds.swf?uu=82abd5491f&vu=1427b918c5&pu=098df6fe6d&auto_play=0&width=640&height=360'+
    
                                                '" id="myFlash"  allownetworking="all">';
		
        //创建"关闭"按钮
        crertdiv("messagemodal" , "a" , "messagea" , "messagea");        
        getobj("messagea").innerHTML = "×";

        //关闭和暂停事件
        getobj("messagea").onclick = function(){
            hidediv("messagediv");
            hideHtml();
            pauseVideo();
        };
    }else{
        var newdiv = getobj("messagediv");
        newdiv.style.display = "block";
        playVideo();
        //html 全屏
        getTagName("html")[0].className += " video-modal"; 
         // timer = setTimeout(function(){hidediv("messagediv");} , 3000);
    }
}

//创建层
function crertdiv(parent , element , id , css)
{
    var newObj = document.createElement(element);

    if(id && id != "")
    {
        newObj.id = id;
    }
    if(css && css != "")
    {
        newObj.className = css;
    }
    if(parent && parent!="")
    {
        var theObj = getobj(parent);
        var parent = theObj.parentNode;
        if(parent.lastChild == theObj)
        {
            theObj.appendChild(newObj);
        }
        else
        {
            theObj.insertBefore(newObj, theObj.nextSibling);
        }
    }
    else
    {
        document.body.appendChild(newObj);
    }
}

//隐藏层
function hidediv(objid)
{
    getobj(objid).style.display = "none";     
}

//关闭html全屏遮罩
function hideHtml(){
    var tagNames = getTagName("html")[0].className;
    if(-1 !== tagNames.indexOf("video-modal")){
        var egex = tagNames.replace(/(video-modal)+/, "");
        getTagName("html")[0].className = egex;
    }
}

//开启视频
function startVideo(url, width, height, controls){
    var video = getobj("videomodal");
    if(url && url != ""){
        video.src = url;
    }
    if(width && width != ""){
        real_width = parseInt(width);
        video.style.width = real_width + "px";
    }
    if(height && height != ""){
        real_height = parseInt(height);
        video.style.height = real_height + "px";
    }
    if(controls && controls != ""){
        video.controls = controls;
    }
    video.play();
}
//暂停后开启
function playVideo(){
    var video = getobj("videomodal");
    video.play();
}

//暂停视频
function pauseVideo(){
    var video = getobj("videomodal");
    video.pause();
}

//获取对象
function getobj(obj)
{
    return document.getElementById(obj);
}

//获取对象
function getTagName(obj)
{
    return document.getElementsByTagName(obj);
}
 